<?php

declare(strict_types=1);

namespace App\Controller\Admin\V1\Admin;

use App\Controller\Admin\V1\Controllers;
use App\Services\Admin\AdminLog as AdminLogServices;

class AdminLog extends Controllers
{
    /**
     * Admin constructor.
     * @param AdminLogServices $adminLogServices
     */
    public function __construct(AdminLogServices $adminLogServices)
    {
        parent::__construct();

        $this->services = $adminLogServices;
    }

    /**
     * 分页
     * @return \Psr\Http\Message\ResponseInterface
     */
    public function page()
    {
        $get = $this->request->query();

        [$field, $order] = $this->orderMap();
        $page = $this->services
            ->search($get)
            ->orderBy($field, $order)
            ->paginate($this->getLimit());

        return success([
            'page' => $page
        ]);
    }
}
